var xmlhttp;
function createRequest()
{
	if(window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if(window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}
}
function getDepts(act)
{
	createRequest();
	xmlhttp.onreadystatechange = statechange1;
	xmlhttp.Open("POST","getJSON.do?method=getDepts&act="+act);
	//xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlhttp.send(null);
	return true;
}
function getPositions(id)
{
	createRequest();
	xmlhttp.onreadystatechange = statechange2;
	xmlhttp.Open("POST","getJSON.do?method=getPositions&deptId="+id);
	xmlhttp.send(null);
}
function fillData(element)
{
	if(xmlhttp.readystate==4)
	{
		if(xmlhttp.status==200)
		{
			element.options.length=0;
			//alert(xmlhttp.responseText);
			element.options.add(new Option("------------请选择------------",""));
			var data = eval('('+xmlhttp.responseText+')');
			for(var i=0;i<data.jsonArray.length;i++)
			{
				var id = data.jsonArray[i].id;
				var name = data.jsonArray[i].name;
				element.options.add(new Option(name,id));
			}
		}
	}
}
function statechange1()
{
if(xmlhttp.readystate==4)
	{
		if(xmlhttp.status==200)
		{
			fillData(document.getElementById("deptId"));
		}
	}
}
function statechange2()
{
if(xmlhttp.readystate==4)
	{
		if(xmlhttp.status==200)
		{
			fillData(document.getElementById("positionId"));
		}
	}
}